
# REFRAN_CONFIG_VERSION(VERSION, [CURRENT], [REVISION], [AGE])
#----------------------------------------------------------
# Setup various version information, especially the libtool versioning
AC_DEFUN([REFRAN_CONFIG_VERSION],
[
    refran_version_string="$1"

    refran_version=`echo "$1" | sed -e 's/[[a-z,A-Z]].*$//'`

    refran_major_version=`echo "$refran_version" | \
    sed 's/\([[0-9]]*\).\(.*\)/\1/'`
    refran_minor_version=`echo "$refran_version" | \
    sed 's/\([[0-9]]*\).\([[0-9]]*\)\(.*\)/\2/'`
    refran_micro_version=`echo "$refran_version" | \
    sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`

    if test -z "$refran_major_version"; then
        refran_major_version=0
    fi

    if test -z "$refran_minor_version"; then
        refran_minor_version=0
    fi

    if test -z "$refran_micro_version"; then
        refran_micro_version=0
    fi

    REFRAN_VERSION="$refran_version"
    REFRAN_VERSION_STRING="$refran_version_string"
    REFRAN_MAJOR_VERSION=$refran_major_version
    REFRAN_MINOR_VERSION=$refran_minor_version
    REFRAN_MICRO_VERSION=$refran_micro_version

    if test -z "$4"; then
        REFRAN_INTERFACE_AGE=0
    else
        REFRAN_INTERFACE_AGE="$4"
    fi

    REFRAN_BINARY_AGE=`expr 256 '*' $REFRAN_MINOR_VERSION + $REFRAN_MICRO_VERSION`
    REFRAN_BINARY_VERSION=`expr 65536 '*' $REFRAN_MAJOR_VERSION + $REFRAN_BINARY_AGE`

    AC_SUBST(REFRAN_VERSION)
    AC_SUBST(REFRAN_VERSION_STRING)
    AC_SUBST(REFRAN_MAJOR_VERSION)
    AC_SUBST(REFRAN_MINOR_VERSION)
    AC_SUBST(REFRAN_MICRO_VERSION)
    AC_SUBST(REFRAN_INTERFACE_AGE)
    AC_SUBST(REFRAN_BINARY_VERSION)
    AC_SUBST(REFRAN_BINARY_AGE)

    AC_DEFINE_UNQUOTED(REFRAN_MAJOR_VERSION, $REFRAN_MAJOR_VERSION,
                       [REFRAN major version number])
    AC_DEFINE_UNQUOTED(REFRAN_MINOR_VERSION, $REFRAN_MINOR_VERSION,
                       [REFRAN minor version number])
    AC_DEFINE_UNQUOTED(REFRAN_MICRO_VERSION, $REFRAN_MICRO_VERSION,
                       [REFRAN micro version number])
    AC_DEFINE_UNQUOTED(REFRAN_INTERFACE_AGE, $REFRAN_INTERFACE_AGE,
                       [REFRAN interface age])
    AC_DEFINE_UNQUOTED(REFRAN_BINARY_VERSION, $REFRAN_BINARY_VERSION,
                       [REFRAN binary version number])
    AC_DEFINE_UNQUOTED(REFRAN_BINARY_AGE, $REFRAN_BINARY_AGE,
                       [REFRAN binary age])

])




#
#  Include debug info in library?
#
AC_DEFUN([REFRAN_ADD_DEBUG_OPTION],
[
   AC_MSG_CHECKING(whether to include debug info in library)
   DEBUG_FLAGS="-O2"
   AC_ARG_ENABLE(debug,
   [
  --enable-debug            include debug info in library (default=no) ],
   [
       if test "$enableval" = "yes" ; then
           DEBUG_FLAGS="-O0 -g3 -ggdb3"
           AC_MSG_RESULT([debug mode enabled])
       else
           DEBUG_FLAGS="-O2"
           AC_MSG_RESULT([debug mode disabled])
       fi
   ])
   CXXFLAGS="$DEBUG_FLAGS $CXXFLAGS"
   AC_SUBST(CXXFLAGS)
])
